from django.db import models


# Create your models here.

class UserModel(models.Model):
    username = models.CharField(max_length=100, default="", verbose_name='昵称')
    phone = models.CharField(max_length=20, unique=True, verbose_name='手机号')
    sex = models.CharField(max_length=20, verbose_name='性别', default="男")
    head_img = models.ImageField(upload_to="upload/", null=True, blank=True, verbose_name="头像")
    birthday = models.DateField(null=True, blank=True, verbose_name="生日")

    class Meta:
        db_table = 'sxuser'

    def __str__(self):
        return self.username


class AddressModel(models.Model):
    user = models.ForeignKey(UserModel, on_delete=models.CASCADE, verbose_name='用户')
    a_name = models.CharField(max_length=100, verbose_name='收货人')
    a_phone = models.CharField(max_length=20, verbose_name='手机号')
    address = models.CharField(max_length=100, verbose_name='地址')
    is_def = models.BooleanField(default=False, verbose_name='是否默认')
    select = models.BooleanField(default=False, verbose_name='是否选中')

    class Meta:
        db_table = 'sxaddress'

    def __str__(self):
        return self.a_name
